package com.changan.controller;

import com.changan.entity.SmbmsUser;
import com.changan.error.BusinessException;
import com.changan.error.EmBusinessError;
import com.changan.response.CommonReturnType;
import com.changan.service.SmbmsUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@Api
public class SmbmsUserController extends BaseController{

    @Autowired
    private SmbmsUserService smbmsUserService;

    /**
     * 代码严格要求不能将实体类等字段直接暴露到接口中
     * @return
     */
    @GetMapping("/lists")
    @ApiOperation(value = "查询所有用户",notes = "查询所有用户返回所有的用户信息")
    public CommonReturnType lists(ArithmeticException e) throws BusinessException {
        /*SmbmsUser smbmsUser = null;
        if(smbmsUser==null){
            throw new BusinessException(EmBusinessError.USET_NOT_EXISTS,"你查询的用户不存在");
        }
        System.out.println(smbmsUser.getAddress());*/

        int[] arr = {1,2,4};
        System.out.println(arr[3]);
        List<SmbmsUser> users = smbmsUserService.list();
        return CommonReturnType.create("fail",users);
    }
}
